﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Media;

namespace UtilZ.Dotnet.WindowsDesktopEx.WPF
{
    /// <summary>
    /// 继承自ToggleButton的扩展类
    /// </summary>
    public class ToggleButtonEx : ToggleButton
    {
        /// <summary>
        /// 文本依赖属性
        /// </summary>
        public static readonly DependencyProperty TextProperty =
            DependencyProperty.Register(nameof(Text), typeof(string), typeof(ToggleButtonEx),
                new FrameworkPropertyMetadata(null, new PropertyChangedCallback(OnPropertyChangedCallback)));

        /// <summary>
        /// 图像依赖属性
        /// </summary>
        public static readonly DependencyProperty ImageProperty =
            DependencyProperty.Register(nameof(Image), typeof(ImageSource), typeof(ToggleButtonEx),
                new FrameworkPropertyMetadata(null, new PropertyChangedCallback(OnPropertyChangedCallback)));


        /// <summary>
        /// 获取或设置文本
        /// </summary>
        public string Text
        {
            get
            {
                return (string)base.GetValue(TextProperty);
            }
            set
            {
                base.SetValue(TextProperty, value);
            }
        }

        /// <summary>
        /// 获取或设置图像
        /// </summary>
        public ImageSource Image
        {
            get
            {
                return (ImageSource)base.GetValue(ImageProperty);
            }
            set
            {
                base.SetValue(ImageProperty, value);
            }
        }



        private static void OnPropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            var selfControl = (ToggleButtonEx)d;
        }

        /// <summary>
        /// 构造函数初始化
        /// </summary>
        public ToggleButtonEx()
        : base()
        {

        }
    }
}
